import type { SidebarsConfig } from "@docusaurus/plugin-content-docs";

// workaround suggested by Docusaurus team: https://github.com/facebook/docusaurus/issues/9902#issuecomment-1972125804
type SidebarConfig = SidebarsConfig[string];
type OnlyArray<Type> = Type extends unknown[] ? Type : never;
type SidebarItemConfigArray = OnlyArray<SidebarConfig>;
type SidebarItemConfig = SidebarItemConfigArray[number];

const platformCategory: SidebarItemConfig = {
  type: "category",
  label: "Platform",
  collapsed: false,
  collapsible: false,
  link: {
    type: "doc",
    id: "platform/index",
  },
  className: "firstTitle",
  items: [{ type: "autogenerated", dirName: "500-platform" }],
};

/**
 * Creating a sidebar enables you to:
 - create an ordered group of docs
 - render a sidebar for each doc of that group
 - provide next/previous navigation

 The sidebars can be generated from the filesystem, or explicitly defined here.

 Create as many sidebars as you want.
 */
const sidebars: SidebarsConfig = {
  // By default, Docusaurus generates a sidebar from the docs folder structure
  gettingStarted: [
    {
      type: "category",
      collapsed: false,
      collapsible: false,
      label: "Get Started",
      link: {
        type: "doc",
        id: "getting-started/index",
      },
      className: "firstTitle",
      items: [
        "getting-started/index",
        // {
        //   type: "doc",
        //   id: "getting-started/quickstart-prismaPostgres",
        //   label: "Quickstart",
        //   customProps: {
        //     badge: "5 Min",
        //   },
        // },
        // {
        //   type: "doc",
        //   id: "getting-started/quickstart-sqlite",
        //   label: "Quickstart",
        //   className: "hidden-sidebar",
        // },
        {
          type: "category",
          label: "Prisma ORM",
          collapsed: false,
          collapsible: false,
          items: [
            {
              type: "category",
              label: "Quickstart",
              collapsed: true,
              collapsible: true,
              className: "hide-category-badge",
              link: {
                type: "doc",
                id: "getting-started/prisma-orm/quickstart/prisma-postgres",
              },
              customProps: {
                hideBadge: true,
              },
              items: [
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/quickstart/prisma-postgres",
                  label: "Prisma Postgres",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/quickstart/mysql",
                  label: "MySQL",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/quickstart/postgresql",
                  label: "PostgreSQL",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/quickstart/sqlite",
                  label: "SQLite",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/quickstart/sql-server",
                  label: "SQL Server",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/quickstart/planetscale",
                  label: "PlanetScale",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/quickstart/cockroachdb",
                  label: "CockroachDB",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/quickstart/mongodb",
                  label: "MongoDB",
                },
              ],
            },
            {
              type: "category",
              label: "Add to existing project",
              collapsed: true,
              collapsible: true,
              className: "hide-category-badge",
              link: {
                type: "doc",
                id: "getting-started/prisma-orm/add-to-existing-project/prisma-postgres",
              },
              customProps: {
                hideBadge: true,
              },
              items: [
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/add-to-existing-project/prisma-postgres",
                  label: "Prisma Postgres",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/add-to-existing-project/mysql",
                  label: "MySQL",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/add-to-existing-project/postgresql",
                  label: "PostgreSQL",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/add-to-existing-project/sqlite",
                  label: "SQLite",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/add-to-existing-project/sql-server",
                  label: "SQL Server",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/add-to-existing-project/planetscale",
                  label: "PlanetScale",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/add-to-existing-project/cockroachdb",
                  label: "CockroachDB",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-orm/add-to-existing-project/mongodb",
                  label: "MongoDB",
                },
              ],
            },
          ],
        },
        {
          type: "category",
          collapsed: false,
          collapsible: false,
          label: "Prisma Postgres",
          link: {
            type: "doc",
            id: "getting-started/prisma-postgres/index",
          },
          items: [
            {
              type: "category",
              label: "Quickstart",
              collapsed: true,
              collapsible: true,
              className: "hide-category-badge",
              link: {
                type: "doc",
                id: "getting-started/prisma-postgres/quickstart/prisma-orm",
              },
              customProps: {
                hideBadge: true,
              },
              items: [
                {
                  type: "doc",
                  id: "getting-started/prisma-postgres/quickstart/prisma-orm",
                  label: "Prisma ORM",
                },
                {
                  type: "category",
                  label: "Other tools",
                  collapsed: false,
                  collapsible: false,
                  className: "sidebar-item-normal-weight",
                  items: [
                    {
                      type: "doc",
                      id: "getting-started/prisma-postgres/quickstart/kysely",
                      label: "Kysely",
                    },
                    {
                      type: "doc",
                      id: "getting-started/prisma-postgres/quickstart/drizzle-orm",
                      label: "Drizzle ORM",
                    },
                    {
                      type: "doc",
                      id: "getting-started/prisma-postgres/quickstart/typeorm",
                      label: "TypeORM",
                    },
                  ],
                },
              ],
            },
            {
              type: "category",
              collapsed: true,
              collapsible: true,
              className: "hide-category-badge",
              label: "Import from existing database",
              link: {
                type: "doc",
                id: "getting-started/prisma-postgres/import-from-existing-database-postgresql",
              },
              customProps: {
                hideBadge: true,
              },
              items: [
                {
                  type: "doc",
                  id: "getting-started/prisma-postgres/import-from-existing-database-postgresql",
                  label: "PostgreSQL",
                  className: "sidebar-item-normal-weight",
                },
                {
                  type: "doc",
                  id: "getting-started/prisma-postgres/import-from-existing-database-mysql",
                  label: "MySQL",
                  className: "sidebar-item-normal-weight",
                },
              ],
            },
            "getting-started/prisma-postgres/from-the-cli",
          ],
        },
      ],
    },
  ],
  ormSidebar: [
    {
      type: "category",
      label: "ORM",
      collapsed: false,
      collapsible: false,
      link: {
        type: "doc",
        id: "orm/orm-index",
      },
      className: "firstTitle",
      items: [{ type: "autogenerated", dirName: "200-orm" }],
    },
  ],
  accelerateSidebar: [
    {
      type: "category",
      label: "Accelerate",
      collapsed: false,
      collapsible: false,
      link: {
        type: "doc",
        id: "accelerate/index",
      },
      className: "firstTitle",
      items: [{ type: "autogenerated", dirName: "300-accelerate" }],
    },
    platformCategory,
  ],
  optimizeSidebar: [
    {
      type: "category",
      label: "Optimize",
      collapsible: false,
      collapsed: false,
      link: {
        type: "doc",
        id: "optimize/index",
      },
      className: "firstTitle",
      items: [{ type: "autogenerated", dirName: "700-optimize" }],
    },
    platformCategory,
  ],
  prismaPostgresSidebar: [
    {
      type: "category",
      label: "Postgres",
      collapsible: false,
      collapsed: false,
      link: {
        type: "doc",
        id: "postgres/index",
      },
      className: "firstTitle",
      items: [{ type: "autogenerated", dirName: "250-postgres" }],
    },
    platformCategory,
  ],
  platformSidebar: [platformCategory],
  aboutSidebar: [
    {
      type: "category",
      label: "About",
      collapsed: false,
      collapsible: false,
      link: {
        type: "doc",
        id: "about/index",
      },
      className: "firstTitle",
      items: [{ type: "autogenerated", dirName: "600-about" }],
    },
  ],
  guidesSidebar: [
    {
      type: "category",
      label: "Guides",
      collapsible: false,
      collapsed: false,
      link: {
        type: "doc",
        id: "guides/index",
      },
      className: "firstTitle",
      items: [
        {
          type: "category",
          label: "Web Frameworks",
          collapsed: false,
          collapsible: false,
          items: [
            "guides/nextjs",
            "guides/nestjs",
            "guides/nuxt",
            "guides/sveltekit",
            "guides/astro",
            "guides/hono",
            "guides/elysia",
            "guides/solid-start",
            "guides/react-router-7",
            "guides/tanstack-start",
            "guides/turborepo",
          ].sort(),
        },
        {
          type: "category",
          label: "Development Tools",
          collapsed: false,
          collapsible: false,
          items: [
            "guides/cloudflare-workers",
            "guides/docker",
            "guides/use-prisma-in-pnpm-workspaces",
            "guides/data-dog",
            "guides/github-actions",
            "guides/bun",
          ].sort(),
        },
        {
          type: "category",
          label: "Integration Solutions",
          collapsed: false,
          collapsible: false,
          items: [
            "guides/clerk-nextjs",
            "guides/clerk-astro",
            "guides/shopify",
            "guides/permit-io-access-control",
            "guides/betterauth-astro",
            "guides/betterauth-nextjs",
            "guides/ai-sdk-nextjs",
            "guides/authjs-nextjs",
            "guides/embed-studio-nextjs",
          ].sort(),
        },
        {
          type: "category",
          label: "Database Management",
          collapsed: false,
          collapsible: false,
          items: [
            "guides/implementing-schema-changes",
            "guides/multiple-databases",
            "guides/cloudflare-d1",
            "guides/data-migration",
          ].sort(),
        },
        {
          type: "category",
          label: "Prisma Postgres for Platforms",
          collapsed: false,
          collapsible: false,
          items: [
            "guides/management-api-basic",
            "guides/management-api",
            "guides/vercel-app-deployment",
            "guides/deno-integration",
          ].sort(),
        },
        {
          type: "category",
          label: "Connection Pooling Guides",
          collapsed: false,
          collapsible: false,
          items: [
            "guides/supabase-accelerate",
            "guides/neon-accelerate",
          ].sort(),
        },
        {
          type: "category",
          label: "ORM Migration",
          collapsed: false,
          collapsible: false,
          items: [
            "guides/migrate-from-typeorm",
            "guides/migrate-from-sequelize",
            "guides/migrate-from-mongoose",
            "guides/migrate-from-drizzle",
          ].sort(),
        },
        {
          type: "category",
          label: "DB Migration",
          collapsed: false,
          collapsible: false,
          items: [
            {
              type: "link",
              label: "Neon",
              href: "/getting-started/prisma-postgres/import-from-existing-database-postgresql",
            },
            {
              type: "link",
              label: "Supabase",
              href: "/getting-started/prisma-postgres/import-from-existing-database-postgresql",
            },
          ],
        },
      ],
    },
  ],
  aiSidebar: [
    {
      type: "category",
      label: "Prisma + AI",
      collapsed: false,
      collapsible: false,
      link: {
        type: "doc",
        id: "ai/index",
      },
      className: "firstTitle",
      items: [
        {
          type: "category",
          label: "Prompts",
          collapsed: false,
          collapsible: false,
          items: [
            "ai/prompts/astro",
            "ai/prompts/nextjs",
            "ai/prompts/prisma-7",
            "ai/prompts/turborepo",
          ],
        },
        {
          type: "category",
          label: "Coding Tools",
          collapsed: false,
          collapsible: false,
          items: [
            "orm/more/ai-tools/cursor",
            "orm/more/ai-tools/windsurf",
            "orm/more/ai-tools/github-copilot",
            "orm/more/ai-tools/chatgpt",
          ],
        },
        {
          type: "category",
          label: "MCP Server",
          collapsed: false,
          collapsible: false,
          items: [
            {
              type: "link",
              label: "Capabilities and Tools",
              href: "/postgres/integrations/mcp-server#tools",
            },
            {
              type: "link",
              label: "Integrating in AI tools",
              href: "/postgres/integrations/mcp-server#integrating-in-ai-tools",
            },
            {
              type: "link",
              label: "How we built it",
              href: "https://www.prisma.io/blog/about-mcp-servers-and-how-we-built-one-for-prisma",
            },
          ],
        },
        {
          type: "category",
          label: "Resources",
          collapsed: false,
          collapsible: false,
          items: [
            {
              type: "link",
              label: "How to Build Apps in the Age of AI",
              href: "https://www.prisma.io/blog/vibe-coding-with-limits-how-to-build-apps-in-the-age-of-ai",
            },
            {
              type: "link",
              label:
                "Vibe Coding an E-commerce App with Prisma MCP and Next.js",
              href: "https://www.prisma.io/blog/vibe-coding-with-prisma-mcp-and-nextjs",
            },
            {
              type: "link",
              label: "Integrating the Vercel AI SDK in a Next.js application",
              href: "/guides/ai-sdk-nextjs",
            },
          ],
        },
        {
          type: "category",
          label: "Integrations",
          collapsed: false,
          collapsible: false,
          items: [
            {
              type: "link",
              label:
                "Automate your workflows with Prisma Postgres and 2,800+ apps",
              href: "https://pipedream.com/apps/prisma-management-api",
            },
            {
              type: "link",
              label:
                "Prompt your application with Firebase Studio & Prisma Postgres",
              href: "/postgres/integrations/idx",
            },
          ],
        },
        // { type: "autogenerated", dirName: "900-ai" }
      ],
    },
  ],
};

export default sidebars;
